package com.itheima.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * @author 刘全
 * @date 2021/9/13
 */
@Repository
public interface AccountDao {

    @Transactional
    @Update("update account set money = money - #{money} where name = #{name}")
    void out(@Param("name") String name,@Param("money") double money);

    @Transactional
    @Update("update account set money = money + #{money} where name = #{name}")
    void in(@Param("name")String name,@Param("money") double money);

    @Transactional
    @Insert("insert into log values(#{date},#{message})")
    void save(@Param("date") Date date, @Param("message") String message);
}
